<?php
/*
* Kusht Mud.
* ----
* The MIT License
* Copyright (c) 2010 Andrew Tutt
* ----
*/

/* Equipment Class
*
*  These are the main method of combat in the game
*/

/* We have some options here because we have done such a good job of abstraction.
*  We could make our items totally straightforward. 
*  Or we could make them really interesting, by screwing with their base
*  stats in all kinds of interesting ways. But that of course requires that we
*  give them some interesting base states. They have to be non-enumerable (we have
*  flags for that). So armor class, damage modifier...and...? 
*  rate of wear, critical hits, variability across items, tweakability (max stats)
*  anything else...? Weapon set (can be determined by script on vnums though)...
*  
*/

class Equipment extends Item {	
	// If you need ExtraDescription, write a MetaText and link to it using Markup
	// Affects inherited from BaseObject.
	// Weight inherited from BaseObject.
	
	// SET IN ALL_FLAGS
	// item_type: Set in All_Flags
	// wear_location: Set in All_Flags
	
	// Base stats
	public $worst_wear_rate; 	// how quickly does it wear out? (increases fragility after 10 hits? 100 hits?)
	public $worst_fragility; 	// How likely is it to break at random? (1 in 1000 or 1 in 100 etc.)
	public $best_ac;			// Armor class
	public $best_dmg;			// how much damage it does
	public $best_speed;			// How fast does it strike?
	public $best_tweakability; 	// How easily is it tweaked? (0-100)
	public $best_max_dmg;		// how much better can it get? (in the best case)
	public $best_max_ac;		// how much better can it get? (in the best base)
	public $best_max_speed;		// The fastest it can get (in the best case)
	
	// The Instanced Values
	public $wear_rate;
	public $fragility;
	public $ac;
	public $dmg;
	public $speed;
	public $tweakability;
	public $max_dmg;
	public $max_ac;
	public $max_speed;
	
	// Create a unique instance of this Equipment
	public function generate() {
		$this->wear_rate	= rand(0,100) * $this->worst_wear_rate / 100;
		$this->fragility	= rand(0,100) * $this->worst_fragility / 100;
		$this->ac			= rand(0,100) * $this->best_ac / 100;		// We use a positive number system because it allows for this sort of adjustment
		$this->dmg			= rand(0,100) * $this->best_dmg / 100;
		$this->speed		= rand(0,100) * $this->best_speed / 100;   // Speed is measured in Hz
		$this->tweakability	= rand(0,100) * $this->best_tweakability / 100;
		$this->max_dmg		= rand(0,100) * $this->best_max_dmg / 100;
		$this->max_ac		= rand(0,100) * $this->best_max_ac / 100;
		$this->max_speed	= rand(0,100) * $this->best_max_speed / 100;
		
		if($this->max_dmg < $this->dmg) 	{ $this->max_dmg = $this->dmg;		}
		if($this->max_ac < $this->ac) 		{ $this->max_ac = $this->ac; 		}
		if($this->max_speed < $this->speed) { $this->max_speed = $this->speed; 	}
	}
}

?>